package com.tom.demo.test;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

import java.io.FileInputStream;

public class JavaFx04 extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("ImageView Experiment 1");

        FileInputStream input = new FileInputStream("1121.jpg");
        Image image = new Image(input);
        ImageView imageView = new ImageView(image);
        //设置图片宽高
        imageView.setFitWidth(1120);
        imageView.setFitHeight(349);
        HBox hbox = new HBox(imageView);

        //这里使用场景中图片的宽高撑开舞台宽高即可
        Scene scene = new Scene(hbox);
        //Scene scene = new Scene(hbox, 1500, 400);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}
